import java.util.*;

/**
 * @author LKQ
 * @date 2022/5/14 10:56
 * @description 前缀异或
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] arr = {1, 3, 4, 8};
        int[][] q = {{0, 1}, {1, 2}, {0, 3}, {3, 3}};
        solution.xorQueries(arr, q);
    }
    public int[] xorQueries(int[] arr, int[][] queries) {
        int n = arr.length;
        int[] xor = new int[n + 1];
        for (int i = 0; i < n; i++) {
            xor[i + 1] = xor[i] ^ arr[i];
        }
        int q = queries.length;
        int[] ans = new int[q];
        for (int i = 0; i < q; i++) {
            int l = queries[i][0], r = queries[i][1];
            ans[i] = xor[r + 1] ^ xor[l];
        }
        return ans;
    }
}
